<template>
	<view class="comment-list u-p-30">
		<view class="comment-list-item" v-for="(item, index) in commentList" :key="index">
			<view class="u-flex u-m-t-30">
				<view>
					<u-avatar :src="item.headimg"></u-avatar>
				</view>
				<view class="nickname u-m-l-30">{{item.nickname}}</view>
			</view>
			<view class="comment-content">评论：{{item.content}}</view>
			<view class="comment-tips u-m-t-30">被评论的内容：{{item.socialpost}}</view>
		</view>
		<u-loadmore v-if="commentList.length" height="80rpx" :status="loadStatus" icon-type="flower"
			color="#ccc" />
	</view>
</template>

<script>
	import Config from '../../common/js/config.js'
	import globalConfig from '@/common/js/golbalConfig.js';
	export default {
		data() {
			return {
               commentList:[],
			   lastPage: 1,
			   currentPage: 1,
			   status: 'loadmore',
			   showEmpty: false,
			}
		},
		onShow() {
			// 刷新多语言
			this.$langConfig.refresh();
		},
		onLoad() {
			this.getCommentlist();
			//登录后查询
			if (uni.getStorageSync('userInfo')) {
				this.member_id = uni.getStorageSync('userInfo').member_id
			}
		},
		onReachBottom() {
            this.getCommentlist();
		},
		mixins: [globalConfig],
		methods: {
			//获取相关数据统计
			getCommentlist() {
				this.showEmpty = false;
				this.$api.sendRequest({
					url: '/social/api/message/comment',
					data: {
						member_id : uni.getStorageSync('userInfo').member_id
					},
					success: res => {
						this.showEmpty = true;
						if (res.code == 0) {
						   this.commentList = [...this.commentList, ...res.data.data];
						   this.isEmpty = !this.commentList.length;
						   this.lastPage = res.data.last_page;
						   this.loadStatus = this.currentPage < res.data.last_page ? 'loadmore' : 'nomore';
						} else {
							this.$util.showToast({
								title: res.message
							});
						}
					},
					fail: res => {
						mescroll.endErr();
						if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
					}
				});
			},
		

		}
	}
</script>

<style>
	.comment-list {
		background: #FFFFFF;
		height: 100vh;
	}
	.comment-tips {
		background: #F3F4F6;
		padding: 25rpx;
	}
</style>
